package org.javaboy.vhr.controller.system.basic;

import org.javaboy.vhr.model.Department;
import org.javaboy.vhr.service.DepartmentService;
import org.javaboy.vhr.responseBean.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/basic/department")
public class DepartmentController {
    @Autowired
    DepartmentService departmentService;

    /**
     * 获取部门列表
     * @return
     */
    @GetMapping("/")
    public ServerResponse getAllDepartment(){
        List<Department> departments = departmentService.getAllDepartment();
        return ServerResponse.success("",departments);
    }

    /**
     * 添加部门
     * @param department
     * @return
     */
    @PostMapping("/")
    public ServerResponse addDept(@RequestBody Department department){
        departmentService.addDept(department);
        return ServerResponse.success("添加成功",department);
    }

    @DeleteMapping("/{id}")
    public ServerResponse deleteDepartmentById(@PathVariable Integer id){
        return departmentService.deleteDepartmentById(id);
    }
}
